cmake_minimum_required( VERSION 3.20 )

# 求大家解惑
if(CMAKE_VERSION VERSION_LESS "3.7.0")
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()

# 限制构建类型为 Debug 和 Release
set(CMAKE_CONFIGURATION_TYPES "Debug;Release")

#dubug -g 调试 GBK 中文
# set (CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -g -fexec-charset=GBK")
# 设置源代码文件的编码为UTF-8
set(CMAKE_CHARSET "UTF-8")
 
# 设置编译器选项以支持UTF-8
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finput-charset=UTF-8")
# 定义根目录
set(SOURCES_ROOT_DIR ${CMAKE_SOURCE_DIR})
set(OUTPUT_ROOT_DIR ${CMAKE_BINARY_DIR})

# 声明一个项目
project(MyGraph)
set(TARGET MyGraph)

file(GLOB SOURCES_FILES 
	"./*.cpp")

file(GLOB HEADER_FILES 
	"./*.h")

# 折叠 ZERO_CHECK 等
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(PREDEFINED_TARGETS_FOLDER "CustomTargets") # 折叠到默认目录
# set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "_CMakePredefinedTargets") # 折叠到指定目录


# set output directories for all builds (Debug, Release, etc.)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
    string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
    set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib )
    set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib )
    set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )

# 添加可执行文件，注意添加WIN32，否则有一个控制台黑框
add_executable(${TARGET} ${SOURCES_FILES} ${HEADER_FILES})

